package designpattern.util;

/**
 * 反射工具类
 */
public class RefletUtil {
    /**
     * 根据全类名获得实例化对象
     * @param name 全类名
     * @return 该对象
     */
    public static Object getObject(String name){
        Class<?> clazz = null;
        Object obj=null;
        try {
            clazz = Class.forName(name);
            obj=clazz.newInstance();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        }
        return obj;
    }
}
